int MSMQOpenQueue(LPSTR pszPathName, DWORD dwAccess, DWORD dwShareMode, QUEUEHANDLE *phQueue) {
HRESULT hr;
char szFullPathName[256];
LPWSTR PathName;
#define BUFSIZE 256
DWORD dwFormatNameBufferLength = BUFSIZE;
WCHAR wszFormatNameBuffer[BUFSIZE];
wsprintf(szFullPathName, ".\\PRIVATE$\\%s", pszPathName);
PathName = Ansi2Unicode(szFullPathName, NULL);
hr = MQPathNameToFormatName(PathName,
wszFormatNameBuffer,
&dwFormatNameBufferLength);
GlobalFree(PathName);
if (FAILED(hr)) {
return hr;
}
hr = MQOpenQueue(wszFormatNameBuffer,
dwAccess,
dwShareMode,
phQueue
);
if (FAILED(hr)) {
return hr;
}
return hr;
} |